package com.fy.restfulapi.condition;

import com.fy.restfulapi.annotation.EnableUnifiedRESTful;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author sunlei
 * @version 1.0
 * @date 2023/7/21 14:44:28
 * @description 当使用了EnableUnifiedRESTful注解，才开启RESTful统一处理结果功能
 */
public class MyConditionalOnEnableRESTfulAnnotation implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return context.getBeanFactory().getBeanNamesForAnnotation(EnableUnifiedRESTful.class).length > 0;
    }
}
